package com.cn.kabalifeuser.ui.my.activity;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.cn.kabalifeuser.R;
import com.cn.kabalifeuser.base.IBaseActivity;
import com.cn.kabalifeuser.ui.integral.activity.CommoditySearchActivity;
import com.cn.kabalifeuser.ui.my.adapter.PagerAdapter;
import com.cn.kabalifeuser.ui.my.bean.IntegralListBean;
import com.cn.kabalifeuser.ui.my.bean.MyUserInfoBean;
import com.cn.kabalifeuser.ui.my.fragment.IntegralListFragments;
import com.cn.kabalifeuser.ui.my.fragment.VipRecommendFragments;
import com.cn.kabalifeuser.ui.my.fragment.VipRightsAndInterestsFragments;
import com.cn.kabalifeuser.utils.GlideUtil;
import com.cn.kabalifeuser.utils.RxToast;
import com.flyco.tablayout.SlidingTabLayout;
import com.flyco.tablayout.listener.OnTabSelectListener;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by 晓林 on 2020/10/30.
 * function: 积分明细
 */
public class IntegralListActivity extends IBaseActivity<IntegralListView, IntegralListPresenter> implements IntegralListView, OnTabSelectListener {
    @BindView(R.id.tv_num)
    TextView tvNum;
    @BindView(R.id.slitab)
    SlidingTabLayout slitab;
    @BindView(R.id.vp_type)
    ViewPager vpType;
    List<String> mList = new ArrayList<>();
    PagerAdapter mAdapter;
    private List<Fragment> mFragments = new ArrayList<>();

    int integral;
    Bundle bundlel;

    @Override
    protected IntegralListPresenter createPresenter() {
        return new IntegralListPresenter();
    }

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_integral_list;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        super.initView(savedInstanceState);
        bundlel = getIntent().getExtras();
        integral = bundlel.getInt("integral");
        tvNum.setText(String.valueOf(integral));
        mList.add("积分收入");
        mList.add("兑换记录");
        mFragments.add(IntegralListFragments.getInstance(1));
        mFragments.add(IntegralListFragments.getInstance(2));
        mAdapter = new PagerAdapter(getSupportFragmentManager(), mList, mFragments);
        vpType.setAdapter(mAdapter);
        vpType.setOffscreenPageLimit((mList.size() - 1));
        slitab.setViewPager(vpType);
        slitab.setOnTabSelectListener(this);
    }

    @Override
    public void onTabSelect(int position) {

    }

    @Override
    public void onTabReselect(int position) {

    }

    @OnClick({R.id.ll_btn_left, R.id.tv_btn_dh})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_btn_left:
                finish();
                break;
            case R.id.tv_btn_dh:
                Bundle bundle = new Bundle();
                bundle.putInt("sign", 1);
                $startActivity(CommoditySearchActivity.class, bundle);
                break;
        }
    }

    @Override
    public void onReLoggedIn(String msg) {
    }

    @Override
    public void onError(String msg) {

    }

    @Override
    public Context _getContext() {
        return null;
    }

    @Override
    public void onListSuccess(IntegralListBean bean) {

    }
}
